home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209s.zip / octave-2.09 / liboctave / Range.h < prev    next >
C/C++ Source or Header  |  1996-12-20  |  2KB  |  97 lines

  1. /*
  2.  
  3. Copyright (C) 1996 John W. Eaton
  4.  
  5. This file is part of Octave.
  6.  
  7. Octave is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by the
  9. Free Software Foundation; either version 2, or (at your option) any
  10. later version.
  11.  
  12. Octave is distributed in the hope that it will be useful, but WITHOUT
  13. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15. for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with Octave; see the file COPYING.  If not, write to the Free
  19. Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  20.  
  21. */
  22.  
  23. #if !defined (octave_Range_h)
  24. #define octave_Range_h 1
  25.  
  26. #if defined (__GNUG__)
  27. #pragma interface
  28. #endif
  29.  
  30. class istream;
  31. class ostream;
  32. class Matrix;
  33.  
  34. class
  35. Range
  36. {
  37.  public:
  38.  
  39.   Range (void)
  40.     : rng_base (-1), rng_limit (-1), rng_inc (-1), rng_nelem (-1) { }
  41.  
  42.   Range (const Range& r)
  43.     : rng_base (r.rng_base), rng_limit (r.rng_limit), rng_inc (r.rng_inc),
  44.       rng_nelem (r.rng_nelem) { }
  45.  
  46.   Range (double b, double l)
  47.     : rng_base (b), rng_limit (l), rng_inc (1),
  48.       rng_nelem (nelem_internal ()) { }
  49.  
  50.   Range (double b, double l, double i)
  51.     : rng_base (b), rng_limit (l), rng_inc (i),
  52.       rng_nelem (nelem_internal ()) { }
  53.  
  54.   double base (void) const { return rng_base;  }
  55.   double limit (void) const { return rng_limit; }
  56.   double inc (void) const { return rng_inc;   }
  57.   int nelem (void) const { return rng_nelem; }
  58.  
  59.   bool all_elements_are_ints (void) const;
  60.  
  61.   Matrix matrix_value (void) const;
  62.  
  63.   double min (void) const;
  64.   double max (void) const;
  65.  
  66.   void sort (void);
  67.  
  68.   void set_base (double b) { rng_base = b;  }
  69.   void set_limit (double l) { rng_limit = l; }
  70.   void set_inc (double i) { rng_inc = i;   }
  71.  
  72.   friend ostream& operator << (ostream& os, const Range& r);
  73.   friend istream& operator >> (istream& is, Range& r);
  74.  
  75.   void print_range (void);
  76.  
  77.  private:
  78.  
  79.   double rng_base;
  80.   double rng_limit;
  81.   double rng_inc;
  82.  
  83.   int rng_nelem;
  84.  
  85.   int nelem_internal (void) const;
  86. };
  87.  
  88. extern Range operator - (const Range& r);
  89.  
  90. #endif
  91.  
  92. /*
  93. ;;; Local Variables: ***
  94. ;;; mode: C++ ***
  95. ;;; End: ***
  96. */
  97.